<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <script src="../static/js/jquery.min.js"></script>
    <link rel="stylesheet" href="../static/css/bootstrap.min.css">
    <script src="../static/js/bootstrap.min.js"></script>
    <title>家族成员</title>
    <link rel="stylesheet" href="style.css">
    <?php
    require_once "session.php";
    $weixin_id=$_SESSION["user"];
    $user = $core->GetUserByWxId($weixin_id);
    $myparent=$core->GetUserById($user["parent_Id"]);//父级;
    $child=$core->GetChildUsersById($user["id"]);
    $child2_num=0;
    $child3_num=0;
    for($a=0;$a<count($child);$a++){
        $child_2=$core->GetChildUsersById($child[$a]["id"]);
        $child2_num+=count($child_2);
        for($b=0;$b<count($child_2);$b++){
            $child_3=$core->GetChildUsersById($child_2[$b]["id"]);
            $child3_num+=count($child_3);
        }
    }
    function ratio($core,$ra){
        $rank=$core->GetRatioByRank($ra);
        return $rank["ratio"];
    }
    ?>
    <style>
        .td_div{
            display: inline-block;
            width: 65px;
            height: 100px;
            overflow-x:hidden;
            overflow-y:auto;
            word-break: break-all;
        }
    </style>
</head>
<body>
<div id="head" style="position: relative;">
    <a href="javascript:history.go(-1)" class="back_btn">
        <span class="glyphicon glyphicon-chevron-left " style="line-height: 45px"></span>
    </a>
    <span style="font-size: 25px;">我的快乐家族</span>
</div>

<div id="MainPanel">
    <div id="header" style="font-size: 20px;padding-top: 20px;padding-left: 20px;">
        我的上级：<?php if($myparent["id"]!=""){
            if($myparent["name"]!=""){
                echo $myparent["name"];
            }else{
                echo "<span style='color:gray'>佚名</span>";
            }
        }else echo "无"; ?>
    </div>
    <div style="height:460px;overflow-y:scroll">
        <table id="members" class="table table-striped table-bordered">
            <tr>
                <td>一级(<?php echo ratio($core,'一级')."%)<br>".count($child);?>人</td>
                <td>二级(<?php echo ratio($core,'二级')."%)<br>".$child2_num;?>人</td>
                <td>三级(<?php echo ratio($core,'三级')."%)<br>".$child3_num;?>人</td>
            </tr>
            <?php

            for($a=0;$a<count($child);$a++){
                $str="";
                ?>

            <tr>
                <td>
                    <div class="td_div">
                           <?php echo "<div>".$child[$a]['name']."</div>"; ?>
                    </div>
                </td>

                <td>
                    <div class="td_div">
                        <?php
                        $child2=$core->GetChildUsersById($child[$a]["id"]);
                        for($b=0;$b<count($child2);$b++){
                            echo "<div>".$child2[$b]['name']."</div>";
                            $child3=$core->GetChildUsersById($child2[$b]["id"]);

                            for($c=0;$c<count($child3);$c++){
                                $str=$str."<div>".$child3[$c]["name"]."</div>";
                            }

                        }?>
                    </div>
                </td>
                <td>
                    <div class="td_div">
                        <?php
                        echo $str;
                        ?>
                    </div>
                </td>
            </tr>
            <?php } ?>

        </table>
    </div>
</div>
<script>
    var height=document.body.scrollHeight;
    document.getElementById("MainPanel").style.height=height+"px";
</script>
</body>
</html>